package pixiv

type loliconResp struct {
	Error string
	Data  []loliconInfo
}

type loliconInfo struct {
	Pid        int               `remarks:"作品pid"`
	P          int               `remarks:"作品所在页"`
	UID        int               `remarks:"作者uid"`
	Title      string            `remarks:"作品标题"`
	Author     string            `remarks:"作品名"`
	R18        bool              `remarks:"是否R18"`
	Width      int               `remarks:"原图宽度"`
	Height     int               `remarks:"原图高度"`
	Tags       []string          `remarks:"作品标签,包含标签的中文翻译"`
	ext        string            `remarks:"图片扩展名"`
	UploadDate int               `remarks:"作品上传日期；时间戳，单位为毫秒"`
	Urls       map[string]string `remarks:"包含了所有指定size的图片地址"`
}

type lolicon struct {
	setu []loliconInfo
}

func (l *lolicon) Send() Info {
	url := "https://api.lolicon.app/setu/v2"
	var data loliconResp
	send("POST", url, &data)
	if data.Error == "" {
		l.setu = data.Data
	}
	return l
}

func (l *lolicon) Get() []Data {
	var data []Data
	for _, v := range l.setu {
		data = append(data, Data{
			Pid:   v.Pid,
			Uid:   v.UID,
			Title: v.Title,
			R18:   v.R18,
			Url:   replace(v.Urls["original"]),
			Proxy: proxy,
		})
	}

	return data
}
